// pages/gps/gps.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    start: "珠海",
    slist: [
     { id: 1, name: "上海" },
     { id: 1, name: "北京" },
     { id: 1, name: "广州" },
     { id: 1, name: "成都" },
     { id: 1, name: "深圳" },
     { id: 1, name: "南京" },
     { id: 1, name: "苏州" },
     { id: 1, name: "西安" },
    ],
    isstart: false,
   },
   opens: function (e) {
    switch (e.currentTarget.dataset.item) {
     case "1":
      if (this.data.isstart) {
       this.setData({
        isstart: false,
       });
      }
      else {
       this.setData({
        isstart: true,
       });
      }
      break;
    }
   },
   onclicks1: function (e) {
    var index = e.currentTarget.dataset.index;
    let name = this.data.slist[index].name;
    this.setData({
     isstart: false,
     isfinish: false,
     isdates: false,
     start: this.data.slist[index].name,
     finish: "目的地"
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
 
    var that = this
    that.latitude = 0
    that.longitude = 0
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        // console.log(res)
        that.latitude = res.latitude
        that.longitude = res.longitude
        that.setData({
          wxml_wd: that.latitude,
          wxml_jd: that.longitude,

        })

      }
    })
    
  },
  
  onShow: function () {

  },
  onLoad: function (options) {

    
      
      var that = this//不要漏了这句，很重要
      wx.request({
        
        url: 'http://192.168.137.1:8080/WEBPRO_18/yu_dz_data' ,
        //localhost:8080
        data: {
        message: 'ty is the The most handsome man in the ESTA',
        },
        method: 'GET',
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          that.setData({
            dz_data : res.data,
            
          });
          console.log(res.data);//回调函数中的携带服务器响应数据
       
        },
        fail: function (res) {
          console.log("fail to connect");
        }
      })
    
      
  },
  set_dz:function(e)
  {
    wx.navigateTo({
      url: '/pages/dz/dz?ID='+e.currentTarget.dataset.s1+'&ID2='+e.currentTarget.dataset.s2,
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})